﻿<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test1.aspx.vb" Inherits="Test" %>

<%@ Register Src="../UserCuntrols/CustomDropDownJSON.ascx" TagName="CustomDropDown"
    TagPrefix="uc1" %>
<%@ Register Src="~/UserCuntrols/footer.ascx" TagName="footer" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Search</title>
    <link href="../App_Themes/myTheme/myTheme.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
    document.Services = "GigitiService.asmx";
    document.SearchTab = 1;
    document.IsKeyWordChanged = false;
    document.IsSearched = false;
    function removeXML(oXml){
            return (oXml.firstChild.textContent)?oXml.firstChild.textContent:oXml.lastChild.text;
    }
   
    Search = function(){
        document.IsKeyWordChanged = true;
        document.IsSearched = true;
        switch(document.SearchTab){
            case 1:
                if($("DropValue").value != ""){
                    YahooWebsearch(1);
                    TopTenRank($("DropValue").value);
                }
                else{
                    YahooWebsearch(3);
                    TopTenYahooSearch();
                }
                EbayWebsearch(1);
                break;
            case 2:
                YahooImageSearch(1);
                break;
            case 3:
                document.location.href = "";
                break;
            case 4:
                YahooVideoSearch(1);
                break;
            case 5:
                YahooNewsSearch(1);
                break;
            default:
                if($("DropValue").value != ""){
                    YahooWebsearch(1);
                    TopTenRank($("DropValue").value);
                }
                else{
                    YahooWebsearch(3);
                    TopTenYahooSearch();
                }
                EbayWebsearch(1);
                break;
        }
        
        $('d_SearchOptionPlace').style.marginTop = "100px";
        OpenTabSearch(document.SearchTab);
    };     
      
    Spellword = function(){
    oParam = '_Word='+$('txtKeyward').value;
    
    new Ajax.Request(document.Services+'/Spellword',{
                    method: 'post',
                    parameters: oParam, 
                    onComplete: _SpellWord
                }
            );
    };
    
    _SpellWord = function(Result){
    //alert(removeXML(Result.responseXML));
    $('lblSpellResult').style.display = "";
     $('lblSpellResult').innerHTML = removeXML(Result.responseXML);
    return false;
    }
    
    ClearSpellWordResult = function(){
        $('lblSpellResult').style.display = "none";
    }
    YahooWebsearch = function(PageIndex){
            $('loaderyahoo').style.display = "";
	        oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
    	    
            new Ajax.Request(document.Services+'/YahooWebsearch',{
                    method: 'post',
                    parameters: oParam, 
                    onComplete: _YahooWebsearch
                }
            );
    };
    _YahooWebsearch = function(Result){
        $('YahooWebsearchResult').innerHTML = removeXML(Result.responseXML);
        $('loaderyahoo').style.display = "none";
        if(document.IsKeyWordChanged){
            document.IsKeyWordChanged = false;
            YahooImageSearch(1);
            YahooVideoSearch(1);
            YahooNewsSearch(1);
        }
    };

    EbayWebsearch = function(PageIndex){
            $('loaderebay').style.display = "";
	        oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
    	    
            new Ajax.Request(document.Services+'/EbayWebsearch',{
                    method: 'post',
                    parameters: oParam, 
                    onComplete: _EbayWebsearch
                }
            );
    };
    _EbayWebsearch = function(Result){
        $('EbayWebsearchResult').innerHTML = removeXML(Result.responseXML);
        $('loaderebay').style.display = "none";
    };

    TopTenYahooSearch = function(){
            $('loadertopten').style.display = "";
	        oParam = 'KeyWard='+$('txtKeyward').value;
    	    
            new Ajax.Request(document.Services+'/YahooWebsearchTopTen',{
                    method: 'post',
                    parameters: oParam, 
                    onComplete: _TopTenYahooSearch
                }
            );
    };
    _TopTenYahooSearch  = function(Result){
        $('TopTenResult').innerHTML = removeXML(Result.responseXML);
        $('loadertopten').style.display = "none";
    };

    TopTenRank = function(SubCategory){
        $('loadertopten').style.display = "";
        
        oParam = 'SubCategory='+SubCategory
    	    
            new Ajax.Request(document.Services+'/TopTenRank',{
                    method: 'post',
                    parameters: oParam, 
                    onComplete: _TopTenRank
                }
            );

    };
    _TopTenRank = function(Result){
        $('TopTenResult').innerHTML = removeXML(Result.responseXML);
        $('loadertopten').style.display = "none";
    };
    AddComments = function(Text){
    };
    
    YahooImageSearch = function(PageIndex){
        //$('loaderyahoo').style.display = "";
        oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
	    
        new Ajax.Request(document.Services+'/YahooImageSearch',{
                method: 'post',
                parameters: oParam, 
                onComplete: _YahooImageSearch
            }
        );
    };
    _YahooImageSearch = function(Result){
        $('d_ImageSearchResult').innerHTML = removeXML(Result.responseXML);
        //$('loaderyahoo').style.display = "none";
        if(document.IsKeyWordChanged){
            document.IsKeyWordChanged = false;
            YahooVideoSearch(1);
            YahooNewsSearch(1);
            YahooWebsearch(1);
        }
    };
    YahooVideoSearch = function(PageIndex){
        //$('loaderyahoo').style.display = "";
        oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
	    
        new Ajax.Request(document.Services+'/YahooVideoSearch',{
                method: 'post',
                parameters: oParam, 
                onComplete: _YahooVideoSearch
            }
        );
    };
    _YahooVideoSearch = function(Result){
        $('d_VideoSearchResult').innerHTML = removeXML(Result.responseXML);
        //$('loaderyahoo').style.display = "none";
        if(document.IsKeyWordChanged){
            document.IsKeyWordChanged = false;
            YahooImageSearch(1);
            YahooNewsSearch(1);
            YahooWebsearch(1);
        }
    };
    YahooNewsSearch = function(PageIndex){
        //$('loaderyahoo').style.display = "";
        oParam = 'KeyWard='+$('txtKeyward').value+'&PageIndex='+PageIndex;
	    
        new Ajax.Request(document.Services+'/YahooNewsSearch',{
                method: 'post',
                parameters: oParam, 
                onComplete: _YahooNewsSearch
            }
        );
    };
    _YahooNewsSearch = function(Result){
        $('d_NewsSearchResult').innerHTML = removeXML(Result.responseXML);
        //$('loaderyahoo').style.display = "none";
        if(document.IsKeyWordChanged){
            document.IsKeyWordChanged = false;
            YahooImageSearch(1);
            YahooVideoSearch(1);
            YahooWebsearch(1);
        }
    };
    OpenTabSearch = function(TabIndex){
        document.SearchTab = TabIndex;
        switch(document.SearchTab){
            case 1:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "";
                    $('d_ImageSearchResult').style.display = "none";
                    $('d_YourGigiti').style.display = "none";
                    $('d_VideoSearchResult').style.display = "none";
                    $('d_NewsSearchResult').style.display = "none";
                }
                $('t_web').className = "s_webtab";
                $('t_image').className = "imagetab"
                $('t_gigiti').className = "gigititab"
                $('t_video').className = "videotab"
                $('t_news').className = "newstab"
                
                $('CustomDropDown1_txtDropdown').style.display = "";
                $('CustomDropDown1_imgDropdown').style.display = "";
                break;
            case 2:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "none";
                    $('d_ImageSearchResult').style.display = "";
                    $('d_YourGigiti').style.display = "none";
                    $('d_VideoSearchResult').style.display = "none";
                    $('d_NewsSearchResult').style.display = "none";
                }
                $('t_web').className = "webtab";
                $('t_image').className = "s_imagetab"
                $('t_gigiti').className = "gigititab"
                $('t_video').className = "videotab"
                $('t_news').className = "newstab"
                $('CustomDropDown1_txtDropdown').style.display = "none";
                $('CustomDropDown1_imgDropdown').style.display = "none";
                break;
            case 3:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "none";
                    $('d_ImageSearchResult').style.display = "none";
                    $('d_YourGigiti').style.display = "";
                    $('d_VideoSearchResult').style.display = "none";
                    $('d_NewsSearchResult').style.display = "none";
                }
                break;
            case 4:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "none";
                    $('d_ImageSearchResult').style.display = "none";
                    $('d_YourGigiti').style.display = "none";
                    $('d_VideoSearchResult').style.display = "";
                    $('d_NewsSearchResult').style.display = "none";
                }
                $('t_web').className = "webtab";
                $('t_image').className = "imagetab"
                $('t_gigiti').className = "gigititab"
                $('t_video').className = "s_videotab"
                $('t_news').className = "newstab"
                
                $('CustomDropDown1_txtDropdown').style.display = "none";
                $('CustomDropDown1_imgDropdown').style.display = "none";
                break;
            case 5:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "none";
                    $('d_ImageSearchResult').style.display = "none";
                    $('d_YourGigiti').style.display = "none";
                    $('d_VideoSearchResult').style.display = "none";
                    $('d_NewsSearchResult').style.display = "";
                }
                $('t_web').className = "webtab";
                $('t_image').className = "imagetab"
                $('t_gigiti').className = "gigititab"
                $('t_video').className = "videotab"
                $('t_news').className = "s_newstab"
                
                $('CustomDropDown1_txtDropdown').style.display = "none";
                $('CustomDropDown1_imgDropdown').style.display = "none";
                break;
            default:
                if (document.IsSearched){
                    $('d_WebSearchResult').style.display = "";
                    $('d_ImageSearchResult').style.display = "none";
                    $('d_YourGigiti').style.display = "none";
                    $('d_VideoSearchResult').style.display = "none";
                    $('d_NewsSearchResult').style.display = "none";
                }
                $('t_web').className = "s_webtab";
                $('t_image').className = "imagetab"
                $('t_gigiti').className = "gigititab"
                $('t_video').className = "videotab"
                $('t_news').className = "newstab"
                
                $('CustomDropDown1_txtDropdown').style.display = "";
                $('CustomDropDown1_imgDropdown').style.display = "";
                break;
        }
    };
    CenterdSearchOptionPlace = function(){
        $('d_SearchOptionPlace').style.marginTop = (window.innerHeight)?(window.innerHeight / 2 - 100) + "px": (window.screen.availHeight / 2 - 180)+"px";
    };
    
    searchKeyPress = function(e){
        if(!e) var e = window.event;
       
        if(e.keyCode == 13){
            Search();
            return false;
        }
    };
    </script>

</head>
<body onload="CenterdSearchOptionPlace();">
    <div id="loader" style="display: none;">
        <div id="jsonloader" class="jsonloader" align="center">
            <img src="../images/loading-spinner.gif" style="margin-top: 200px;" alt="Loadin..."
                title="Loading..." /></div>
    </div>
    
    <form id="form1" runat="server">
    <img src="../images/background.gif" style="border-width:0px;width:99.8%;position:absolute;z-index:1;" />
    <table width="100%" border="0" cellpadding="0" cellspacing="0" style="z-index:2;position:absolute;">
        <tr>
            <td width="50">
            </td>
            <td style="min-height: 600px;" align="center">
            
                <div style="z-index:2;">
                <div align="center" id="d_SearchOptionPlace" style="margin-top: 100px;">
                    <div>
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td class="s_webtab" id="t_web" onclick="OpenTabSearch(1);">
                                </td>
                                <td class="imagetab" id="t_image" onclick="OpenTabSearch(2);">
                                </td>
                                <td class="gigititab" id="t_gigiti" onclick="OpenTabSearch(3);">
                                </td>
                                <td class="videotab" id="t_video" onclick="OpenTabSearch(4);">
                                </td>
                                <td class="newstab" id="t_news" onclick="OpenTabSearch(5);">
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="searchlogo">
                        <div style="padding-top: 40px; padding-left: 40px;"> 
                        <div ><asp:Label ID="lblSpellResult" runat="server"></asp:Label>
                        <input type="button" id="lnkBtnSpell" value="Check Spelling" onclick="Spellword(); return false;" /></div>
                                       
                            <input id="txtKeyward" type="text" class="aspTextBox" onclick="ClearSpellWordResult();"/>
                            <uc1:CustomDropDown ID="CustomDropDown1" runat="server" DataXML="~/XML/Menu.xml" />
                            <img id="btnSearch" src="../images/GigitiButton4.gif" onclick="Search();return false;"
                                alt="Search" title="Click to search specified keyword" style="cursor: pointer;
                                margin-top: -3px;" />
                        </div>
                    </div>
                </div>

                <script language="javascript" type="text/javascript">
        $('txtKeyward').onkeypress = searchKeyPress;
                </script>

                <div style="width: 100%; float: left;" align="center">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td align="center">
                                <div id="d_WebSearchResult" style="display: none;">
                                    <asp:Panel ID="TopTen" runat="server" CssClass="aspPanelResult">
                                        <asp:Image ImageUrl="~/images/spacer.gif" Style="height: 35px;" ID="imgLogoSpace"
                                            runat="server" />
                                        <table cellspacing="0" cellpadding="0" width="100%" border="0">
                                            <tbody>
                                                <tr height="24">
                                                    <td width="24">
                                                        <asp:Image ID="Image2" runat="server" ImageUrl="~/images/blue/topleft_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="topHeader_blue" align="left">
                                                        Top Ten
                                                    </td>
                                                    <td width="1" style="width: 1px;" class="topHeader_blue">
                                                        <asp:Image ID="Image3" runat="server" ImageUrl="~/images/blue/topright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="topBorder_blue">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image4" runat="server" ImageUrl="~/images/blue/topright_bgcornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td class="leftBorder_blue">
                                                    </td>
                                                    <td bgcolor="#ffffff" colspan="3" height="50">
                                                        <div id="loadertopten" style="display: none;" class="jsonloader" align="center">
                                                            <img src="../images/loading-spinner.gif" style="margin-top: 200px;" alt="Loadin..."
                                                                title="Loading..." /></div>
                                                        <div id="TopTenResult" class="WebSearchPanel" style="overflow: auto;">
                                                        </div>
                                                    </td>
                                                    <td class="rightBorder_blue">
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image5" runat="server" ImageUrl="~/images/blue/bottomleft_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="bottomBorder_blue" colspan="3">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image6" runat="server" ImageUrl="~/images/blue/bottomright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </asp:Panel>
                                    <asp:Panel ID="Yahoo" runat="server" CssClass="aspPanelResult">
                                        <asp:Image ImageUrl="~/images/yahoo.gif" Style="height: 20px; margin-top: 10px; margin-bottom: 5px;"
                                            ID="imgLogoGoogle" runat="server" />
                                        <table cellspacing="0" cellpadding="0" width="100%" border="0">
                                            <tbody>
                                                <tr height="24">
                                                    <td width="24">
                                                        <asp:Image ID="img6" runat="server" ImageUrl="~/images/blue/topleft_cornor.gif" ImageAlign="right" />
                                                    </td>
                                                    <td class="topHeader_blue" align="left">
                                                        Yahoo Results
                                                    </td>
                                                    <td width="1" style="width: 1px;">
                                                        <asp:Image ID="img7" runat="server" ImageUrl="~/images/blue/topright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="topBorder_blue">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="img8" runat="server" ImageUrl="~/images/blue/topright_bgcornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td class="leftBorder_blue">
                                                    </td>
                                                    <td bgcolor="#ffffff" colspan="3" height="50">
                                                        <div id="loaderyahoo" style="display: none;" class="jsonloader" align="center">
                                                            <img src="../images/loading-spinner.gif" style="margin-top: 200px;" alt="Loadin..."
                                                                title="Loading..." /></div>
                                                        <div id="YahooWebsearchResult" class="WebSearchPanel">
                                                        </div>
                                                    </td>
                                                    <td class="rightBorder_blue">
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td valign="bottom">
                                                        <asp:Image ID="img9" runat="server" ImageUrl="~/images/blue/bottomleft_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="bottomBorder_blue" colspan="3">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="img10" runat="server" ImageUrl="~/images/blue/bottomright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </asp:Panel>
                                    <asp:Panel ID="Ebay" runat="server" CssClass="aspPanelResult">
                                        <asp:Image ImageUrl="~/images/ebay.gif" ID="Image1" runat="server" />
                                        <table cellspacing="0" cellpadding="0" width="100%" border="0">
                                            <tbody>
                                                <tr height="24">
                                                    <td width="24">
                                                        <asp:Image ID="Image8" runat="server" ImageUrl="~/images/blue/topleft_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="topHeader_blue" align="left">
                                                        Ebay Results
                                                    </td>
                                                    <td width="1" style="width: 1px;">
                                                        <asp:Image ID="Image9" runat="server" ImageUrl="~/images/blue/topright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="topBorder_blue">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image10" runat="server" ImageUrl="~/images/blue/topright_bgcornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td class="leftBorder_blue">
                                                    </td>
                                                    <td bgcolor="#ffffff" colspan="3" height="50">
                                                        <div id="loaderebay" style="display: none;" class="jsonloader" align="center">
                                                            <img src="../images/loading-spinner.gif" style="margin-top: 200px;" alt="Loadin..."
                                                                title="Loading..." /></div>
                                                        <div id="EbayWebsearchResult" class="WebSearchPanel">
                                                        </div>
                                                    </td>
                                                    <td class="rightBorder_blue">
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image11" runat="server" ImageUrl="~/images/blue/bottomleft_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                    <td class="bottomBorder_blue" colspan="3">
                                                    </td>
                                                    <td valign="bottom">
                                                        <asp:Image ID="Image12" runat="server" ImageUrl="~/images/blue/bottomright_cornor.gif"
                                                            ImageAlign="right" />
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </asp:Panel>
                                </div>
                                <div id="d_ImageSearchResult" class="ImageSearchResultPanel" align="center" style="display: none;">
                                </div>
                                <div id="d_VideoSearchResult" class="VideoSearchResultPanel" align="center" style="display: none;">
                                </div>
                                <div id="d_NewsSearchResult" style="display: none;">
                                </div>
                            </td>
                        </tr>
                    </table>
                    <div id="d_YourGigiti" style="display: none;">
                    </div>
                </div>
                </div>
                
            </td>
            <td width="50">
            </td>
        </tr>
        <tr height="50">
            <td width="50">
            </td>
            <td align="center">
                <uc1:footer ID="footer1" runat="server" />
            </td>
            <td width="50">
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
